package com.vincent.kdp.util;

import android.text.TextUtils;

/**
 * Created by fuxingxing on 17/2/15.
 */

public class RegexUtils {

    public static String EMPTY="";

    //判断身份证号的正则表达式
    public static boolean isPostCard(String postcard) {
        String telRegex ="(^\\d{15}$)|(^\\d{17}([0-9]|X)$)";
        if (TextUtils.isEmpty(postcard)) return false;
        else return postcard.matches(telRegex);
    }
    //判断手机号的正则表达式
    public static boolean isMobileNO(String mobiles) {
        String telRegex = "^((13[0-9])|(15[^4,\\D])|(18[0,2-9])|(17[0-9]))\\d{8}$";
        if (TextUtils.isEmpty(mobiles)) return false;
        else return mobiles.matches(telRegex);
    }

    public static String trimNull(Object obj){
        if(obj==null) return EMPTY;
        return obj.toString();
    }
    ;

    public static boolean isEmail(String email) {
        String telRegex = "/^[a-z]([a-z0-9]*[-_]?[a-z0-9]+)*@([a-z0-9]*[-_]?[a-z0-9]+)+[\\.][a-z]{2,3}([\\.][a-z]{2})?$/i";
        if (TextUtils.isEmpty(email)) return false;
        else return email.matches(telRegex);
    }
}
